//
//  SurpriseShopDataModel.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/12.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class SurpriseShopDataModel: NSObject {
    var type_list = [SurpTypeListModel]()
    var datas : SurpriseSubDatasModel?
    var headline_list = [SurpriseHeadLineModel]()
    var code = "-999"
    var pre_list = [SupriseDataListModel]()
    var hasmore = "-999"
    var msg = "-999"
    var page_total = "-999"
    
    init(dic : [String : AnyObject]) {
        super.init()
        
        setValuesForKeys(dic)
        
    }
    
    
    override func  setValue(_ value: Any?, forKey key: String) {
        
        if key == "type_list" {
            
            
                if let temp = value as? [[String : AnyObject]]{
                    
                    for dic in temp {
                        
                        type_list.append(SurpTypeListModel(dic:dic ))
                    }
                    
                    
                }

            
        } else if key == "datas" {
            
            
            if let temp = value as? [String : AnyObject]{
                
                datas = SurpriseSubDatasModel(dic:temp )
                
            }

            
        } else if key == "headline_list" {
            
            if let temp = value as? [[String : AnyObject]]{
                
                for dic in temp {
                    
                    headline_list.append(SurpriseHeadLineModel(dic:dic ))
                }
                
                
            }

            
        } else if key == "pre_list" {
            
            if let temp = value as? [[String : AnyObject]]{
                
                for dic in temp {
                    
                    pre_list.append(SupriseDataListModel(dic:dic ))
                }
                
                
            }

        }else{
        
        
            super.setValue(value, forKey: key)

        
        }
        
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
        
    }
    
    
    //在swift中想要打印对象要以下重写属性
    override var description: String{
        let keys = ["type_list","datas","headline_list","code","pre_list","hasmore","msg","page_total"]
        let dic = dictionaryWithValues(forKeys: keys)
        return "\(dic)"
    }

}
